import { createBrowserRouter } from 'react-router-dom'

import { TabPageRoot } from '@/components'
import { CONST_ROUTES } from '@/constants'

const router = createBrowserRouter([
  {
    path: CONST_ROUTES.INDEX,
    element: <TabPageRoot />,
    children: [
      {
        index: true,
        lazy: async () => ({
          Component: (await import('@/pages/index')).default
        })
      },
      {
        path: CONST_ROUTES.CATEGORY,
        lazy: async () => ({
          Component: (await import('@/pages/category')).default
        })
      },
      {
        path: CONST_ROUTES.SHOP,
        lazy: async () => ({
          Component: (await import('@/pages/shop')).default
        })
      },
      {
        path: CONST_ROUTES.CART,
        lazy: async () => ({
          Component: (await import('@/pages/cart')).default
        })
      },
      {
        path: CONST_ROUTES.MY,
        lazy: async () => ({
          Component: (await import('@/pages/my')).default
        })
      }
    ]
  },
  {
    path: CONST_ROUTES.LOGIN,
    lazy: async () => ({
      Component: (await import('@/pages/login')).default
    })
  },
  {
    path: '/other',
    lazy: async () => ({
      Component: (await import('@/pages/other')).default
    })
  }
])

export default router
